package com.demo.factory.simpleFactory.pizzastore.order;

import com.demo.factory.simpleFactory.pizzastore.pizza.CheesePizza;
import com.demo.factory.simpleFactory.pizzastore.pizza.GreekPizza;
import com.demo.factory.simpleFactory.pizzastore.pizza.Pizza;

// 简单工厂类
public class SimpleFactory {

    // 根据类型，返回对应的pizza对象
    public Pizza createPizza(String orderType) {
        Pizza pizza = null;
        System.out.println("使用简单工厂模式");
        if (orderType.equals("greek")) {
            pizza = new GreekPizza();
            pizza.setName("Greek");
        } else if (orderType.equals("cheese")) {
            pizza = new CheesePizza();
            pizza.setName("Cheese");
        }
        return pizza;
    }
}
